#pragma once

#include <winsock2.h>		// Note: This header should be included ahead of any other header
#include <windows.h>
#include <ws2tcpip.h>
#pragma comment(lib, "ws2_32.lib")
#include <stdio.h>
#include <tchar.h>

#include <tlhelp32.h>

// Convert a pointer to char to a pointer to wchar
#define Str2WStr(strSrc, wstrDst, nDstSize) \
	MultiByteToWideChar(CP_ACP, 0, strSrc, -1, wstrDst, nDstSize)

// Convert a pointer to wchar to a pointer to char
#define WStr2Str(wstrSrc, strDst, nDstSize) \
	WideCharToMultiByte(CP_OEMCP, NULL, wstrSrc, -1, strDst, nDstSize*sizeof(char), NULL, FALSE)

// Delete all contents of a specified directory
void DeleteFolderContent(char * strDir);

// Imitate OpenMP function omp_get_num_procs
int omp_get_num_procs_from_file(char * strFilename);

// Invoke a windows application
bool CallExe(char * strCmd, bool bDispInfo = NULL, DWORD * pwdExitCode = NULL);

// Adjust the working directory to the place where current module is loaded
bool AdjustProcessCurrentDirectory();

// Find the process ID according to the process name
DWORD FindProcessID(char * strProcess);

// Invoke a windows application via pipe
bool CallExeViaPipe(char * strCmd, char * strBuffer, int nBufLen);

// Winsock API
bool GetIpAddressByHostName (char * strIpAddress, int nIpAddLen, char * strHostName);

// Winsock API
bool GetHostNameByIpAddress (char * strHostName, int nHstNmLen, char * strIpAddress);